/* 
 * File:   DynamicDataEntry.h
 * Author: jeffrey
 *
 * Created on June 21, 2010, 3:11 AM
 */

#ifndef _DYNAMICDATAENTRY_H
#define	_DYNAMICDATAENTRY_H
#include <string>
#include <vector>
#include "Section.h"

using namespace std;

class DynamicDataEntry {
public:
    DynamicDataEntry();
    DynamicDataEntry(const DynamicDataEntry& orig);
    virtual ~DynamicDataEntry();
    string getContent(int entryNo);

    void addContent(string s);
    void modifyContent(string s, int entryNo);
    void removeContent(int entryNo);

    friend ostream & operator<<(ostream&, const DynamicDataEntry&);
    void print();
   

    


private:
    //An entry has several numbered columns
    //Each column contains a string, one of which holds the actual data string.

    //The semantics for each column are defined in the header.
    //We use the section container because of the convienient buildfile methods.
    Section<string> entry;
    int datastringcomponent;


};

DynamicDataEntry::DynamicDataEntry() {
}

DynamicDataEntry::DynamicDataEntry(const DynamicDataEntry& orig) {
    entry = orig.entry;
    datastringcomponent = orig.datastringcomponent;
}

DynamicDataEntry::~DynamicDataEntry() {
}

string DynamicDataEntry::getContent(int entryNo){
    return entry.get(entryNo);
}



void DynamicDataEntry::addContent(string s){
    entry.add(s);
}

void DynamicDataEntry::modifyContent(string s, int entryNo){
    entry.modify(s,entryNo);
}

void DynamicDataEntry::removeContent(int entryNo){
    entry.remove(entryNo);
}

ostream & operator<<(ostream& output, const DynamicDataEntry& data) {
    //Ask Dates
    DynamicDataEntry stupid;
    stupid = data;
    vector<string> x;
    x = stupid.entry.getSectionData();
    vector<string>::iterator It1;
    string format;
    format = "(";
    for (It1 = x.begin(); It1 != x.end(); ++It1){
        string& value = (*It1);
        format.append(value);
        format.append(";");
    }
    format.append(")");
    return output << format << "\n";

}
void DynamicDataEntry::print() {
    vector<string>& x = entry.getSectionData();
    vector<string>::iterator It1;
    string format;
    format = "(";
    for (It1 = x.begin(); It1 != x.end(); ++It1){
        string& value = (*It1);
        format.append(value);
        format.append(";");
    }
    format.append(")");
    cout << format << endl;
}

/*
void DynamicDataEntry::buildFile(string path){
    vector x;
    entry.buildFile(path);
}
 * */
#endif	/* _DYNAMICDATAENTRY_H */

